//------------Sonic CD BGEffects Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 16: TYPE_BGEFFECTS


sub ObjectDraw
	SetActivePalette(1,128,Screen.YSize)
	if TileLayer[0].Angle==0
		TempValue0=0
	else
		TempValue0=512
		TempValue0-=TileLayer[0].Angle
	endif
	TempValue1=TempValue0
	TempValue0*=3
	TempValue1<<=1
	TempValue1/=4
	TempValue1>>=1
	TempValue0+=TempValue1
	TempValue1=TempValue0
	TempValue1&=127
	FlipSign(TempValue1)
	TempValue0>>=7
	while TempValue1<Screen.XSize
		DrawSpriteScreenXY(TempValue0,TempValue1,0)
		TempValue0++
		if TempValue0==13
			TempValue0=0
		endif
		TempValue1+=128
	loop
endsub


sub ObjectStartup
	SetMusicTrack("SS1.ogg",0,1)
	SetMusicTrack("SS1Finish.ogg",1,0)
	Stage.XBoundary1=1048576
	Stage.XBoundary2=267386880
	Stage.YBoundary1=42991616
	Stage.YBoundary2=219283456
	HParallax[0].ScrollPos+=983040
#platform: HW_Rendering
	LoadSpriteSheet("Special/SSMap1.gif")
#endplatform
	LoadSpriteSheet("Special/SSBG1A.gif")
	TempValue0=0
	while TempValue0<1664
		SpriteFrame(0,0,128,256,TempValue0,0)
		TempValue0+=128
	loop
	LoadPalette("SS1BGA.act",0,100,0,156)
	CopyPalette(0,1)
	LoadPalette("SS1BGAW.act",1,100,0,156)
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[BGEffects]
			Object[ArrayPos0].Priority=1
			Object[ArrayPos0].DrawOrder=0
			Object[ArrayPos0].Value2=368
		endif
		ArrayPos0++
	loop
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
